package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 使用反射机制调用有参方法
 */
public class ReflectDemo5 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {

        Class cls = Class.forName("reflect.Person");
        Object object = cls.newInstance();
        Method method = cls.getMethod("say", String.class,int.class);
        method.invoke(object,"大家好!",5);


    }
}
